#include "comm.hpp"
#define SIZE 4096
#define fifoname "./fifo"
int main(){
    int shmid = getShm(SIZE);//获取共享内存
    char* addr = (char*)shmat(shmid,nullptr,0);//链接共享内存到地址空间
    log("debug","\"shmat shared memory\" success",__FILE__,__LINE__);
    int fd = open(fifoname,O_WRONLY);
    if(fd<0){
        log("error","\"open\" failed",__FILE__,__LINE__);
    }//命名管道打开成功
    log("debug","\"mkfifo and open fifo\" success",__FILE__,__LINE__);

    while(true){
        cin>>addr;
        if(strcmp(addr,"quit") == 0) break;//退出通信
        write(fd,"c",1);
    }
    close(fd);
    shmdt(addr);
    return 0;
}